{% extends '@Admin/adminFramework/example/edit.html.twig' %}
{% import '@Admin/adminFramework/config.html.twig' as config %}


{% block title %}权限分配{% endblock %}
{% block input %}
    <div class="row" style="margin-left: 5px">
        <div class="span5">
            未分配:
            <input id="search-avaliable"><br>
            <select id="list-avaliable" multiple size="20" style="width: 100%; margin-top: 5px">
            </select>
        </div>
        <div class="span1">
            <br><br><br>
            <a href="#" id="btn-add" class="btn btn-success">&gt;&gt;</a><br>
            <a href="#" id="btn-remove" class="btn btn-danger">&lt;&lt;</a>
        </div>
        <div class="span5">
            已分配:
            <input id="search-assigned"><br>
            <select id="list-assigned" multiple size="20" style="width: 100%; margin-top: 5px">
            </select>
        </div>
    </div>
{% endblock %}

{% block button %}
{% endblock %}
{% block before %}
    {{ loader_model.load_navigation('角色管理', '权限管理', { '权限分配列表':path('admin_assignment_assign'),'角色管理':'' }) }}
{% endblock %}
{% block jquery %}
    {{ parent() }}
    <script type="text/javascript" src="{{ asset('bundles/admin/js/permission.js') }}"></script>
    <script>
        jQuery(document).ready(function () {
            permission.initProperties({"userId": "{{ admin.id }}", "assignUrl": "{{ path('admin_assignment_assign') }}", "searchUrl": "{{ path('admin_assignment_search') }}"});

            $('#search-avaliable').keydown(function () {
                permission.searchRole('avaliable');
            });
            $('#search-assigned').keydown(function () {
                permission.searchRole('assigned');
            });
            $('#btn-add').click(function () {
                permission.assign('assign');
                return false;
            });
            $('#btn-remove').click(function () {
                permission.assign('remove');
                return false;
            });

            permission.searchAssignmet('avaliable', true);
            permission.searchAssignmet('assigned', true);
        });
    </script>
{% endblock %}